package com.ruoyi.bond.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bond.domain.BondZhCovInfoThs;
import com.ruoyi.bond.service.IBondZhCovInfoThsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 可转债详情-同花顺Controller
 * 
 * @author leng.xz
 * @date 2024-05-17
 */
@Controller
@RequestMapping("/bond/ZhCovInfoThs")
public class BondZhCovInfoThsController extends BaseController
{
    private String prefix = "bond/ZhCovInfoThs";

    @Autowired
    private IBondZhCovInfoThsService bondZhCovInfoThsService;

    @RequiresPermissions("bond:ZhCovInfoThs:view")
    @GetMapping()
    public String ZhCovInfoThs()
    {
        return prefix + "/ZhCovInfoThs";
    }

    /**
     * 查询可转债详情-同花顺列表
     */
    @RequiresPermissions("bond:ZhCovInfoThs:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BondZhCovInfoThs bondZhCovInfoThs)
    {
        startPage();
        List<BondZhCovInfoThs> list = bondZhCovInfoThsService.selectBondZhCovInfoThsList(bondZhCovInfoThs);
        return getDataTable(list);
    }

    /**
     * 导出可转债详情-同花顺列表
     */
    @RequiresPermissions("bond:ZhCovInfoThs:export")
    @Log(title = "可转债详情-同花顺", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BondZhCovInfoThs bondZhCovInfoThs)
    {
        List<BondZhCovInfoThs> list = bondZhCovInfoThsService.selectBondZhCovInfoThsList(bondZhCovInfoThs);
        ExcelUtil<BondZhCovInfoThs> util = new ExcelUtil<BondZhCovInfoThs>(BondZhCovInfoThs.class);
        return util.exportExcel(list, "ZhCovInfoThs");
    }

    /**
     * 新增可转债详情-同花顺
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存可转债详情-同花顺
     */
    @RequiresPermissions("bond:ZhCovInfoThs:add")
    @Log(title = "可转债详情-同花顺", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BondZhCovInfoThs bondZhCovInfoThs)
    {
        return toAjax(bondZhCovInfoThsService.insertBondZhCovInfoThs(bondZhCovInfoThs));
    }

    /**
     * 修改可转债详情-同花顺
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BondZhCovInfoThs bondZhCovInfoThs = bondZhCovInfoThsService.selectBondZhCovInfoThsById(id);
        mmap.put("bondZhCovInfoThs", bondZhCovInfoThs);
        return prefix + "/edit";
    }

    /**
     * 修改保存可转债详情-同花顺
     */
    @RequiresPermissions("bond:ZhCovInfoThs:edit")
    @Log(title = "可转债详情-同花顺", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BondZhCovInfoThs bondZhCovInfoThs)
    {
        return toAjax(bondZhCovInfoThsService.updateBondZhCovInfoThs(bondZhCovInfoThs));
    }

    /**
     * 删除可转债详情-同花顺
     */
    @RequiresPermissions("bond:ZhCovInfoThs:remove")
    @Log(title = "可转债详情-同花顺", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bondZhCovInfoThsService.deleteBondZhCovInfoThsByIds(ids));
    }
}
